#ifndef __TRAIN__
#define __TRAIN__
#include <my_header.h>
typedef struct train_s{
    int flag;//新增加的
    int length;
    char data[1000];        
}train_t;
int transFile(int netfd,train_t * train)//要调整
{
    send(netfd,&train->flag,sizeof(train->flag),MSG_NOSIGNAL);
    send(netfd,&train->length,sizeof(train->length),MSG_NOSIGNAL);
    send(netfd,train->data,train->length,MSG_NOSIGNAL);

    return 0;
}
//版本2.1   小火车循环大文件                        
////MSG_WAITALL解决半包问题或者recvn设置一个自定义recv
int recvn(int sockfd,void *buf,int length)
{
    int total=0;
    char * map=(char *)buf;
    while(total<length)
    {//从哪里接受   接受的位置     接受多长   
        ssize_t ret=recv(sockfd,map+total,length-total,0);
        total+=ret;
    }
    return total;

}
int recvFile(int netfd,train_t * train)//要调整                                                       
{   
    recvn(netfd,&train->flag,sizeof(train->flag));
    recvn(netfd,&train->length,sizeof(train->length));
    recvn(netfd,train->data,train->length);
    return 0;          

}                      
#endif

